package cn.toutatis.basics

/**
 * 02-函数
 * */
class A02_Function {

    fun sum1(a: Int, b: Int): Int {
        return a + b
    }

    /*将表达式作为函数体、返回值类型自动推断的函数*/
    fun sum2(a: Int, b: Int) = a + b

    /*函数返回无意义的值*/
    fun printSum1(a: Int, b: Int): Unit {
        println("sum of $a and $b is ${a + b}")
    }

    /*Unit 返回类型可以省略*/
    fun printSum2(a: Int, b: Int) {
        println("sum of $a and $b is ${a + b}")
    }

}

fun main(){
    val function02 = A02_Function()
    val sum1 = function02.sum1(1, 2)
    System.err.println(sum1)
    val sum2 = function02.sum2(2, 2)
    System.err.println(sum2)
}